﻿using hentity;
using hlog;
using System.IO;
using System.Web.Http;
 namespace hhttp {
    public class BaseApiController : ApiController
    {
        public BaseResult Options()
        {
            BaseResult baseResult = new BaseResult("不支持的请求方式Options");
            return baseResult;
        }
        public BaseResult Put(int id, [FromBody]string value)
        {
            BaseResult baseResult = new BaseResult("不支持的请求方式Put");
            return baseResult;
        }
         public BaseResult Delete(int id)
        {
            BaseResult baseResult = new BaseResult("不支持的请求方式Delete");
            return baseResult;
        }
         virtual public BaseResult Post([FromBody]string value)
        {
            BaseResult baseResult = new BaseResult("不支持的请求方式Post");
            return baseResult;
          }

        public byte[] getPrint(string name) {

            string currentPath = System.AppDomain.CurrentDomain.BaseDirectory;
            string html =  Path.Combine(currentPath ,"Conf" ,"print" ,name);
            byte[] b= FileCache.loadFile(html);
            return b;
        }

        public string getPrintUtf8(string name) {
            byte[] b = getPrint( name);
            return System.Text.Encoding.UTF8.GetString(b);
           
        }
        public string getPrintDefaut(string name) {
            byte[] b = getPrint(name);
            return System.Text.Encoding.Default.GetString(b);

        }
    }
}
